namespace FIREFLYX {
    export class ShaderProcessor implements IAssetProcessor {
        public Type: AssetType = AssetType.SHADER;
        public suffix: string = ".shader.json";
        public rawType: XMLHttpRequestResponseType = "json";
        public parse(data: any, filePath: string): Nullable<Asset> {
            let shader = new Shader();
            shader.filePath = filePath;
            shader.tag = data.tag ?? "";
            shader.lightMode = data.lightMode ?? "";
            shader.vertexFile = data.vs ?? "";
            shader.fragmentFile = data.fs ?? "";
            //属性
            let property = data.property;
            if (property) {
                shader.definePropertyMap = {};
                let dpMap = shader.definePropertyMap;
                const keys = Object.keys(property);
                for (let i = 0, len = keys.length; i < len; i++) {
                    const k = keys[i];
                    let p = property[k];
                    dpMap[k] = {
                        type: p.type,
                        value: p.value
                    };
                }
            }
            //shader JIT 编译模式，不需要预先编译组合设置了 
            // //变体关键字
            // //多编译
            // let multiCompiles = data.multi_compiles as string[][];
            // if (multiCompiles) {
            //     shader.multiCompiles = [];
            //     for (let i = 0, len = multiCompiles.length; i < len; i++) {
            //         const m = multiCompiles[i];
            //         shader.multiCompiles.push(m.concat());
            //     }
            // }

            return shader;
        }
    }
}